<?php

namespace App\Http\Controllers\Backend\Api\V1;

use App\Http\Requests\Backend\DesignerRequest;
use App\Services\Gallery\Interfaces\DesignerServiceInterface;
use App\Services\Gallery\Model\Designer;
use App\Services\Gallery\Services\DesignerService;
use Illuminate\Http\Request;

class DesignerController extends BaseController
{
    /**
     * @var DesignerService
     */
    protected $designerService;

    public function __construct(DesignerServiceInterface $designerService)
    {
        $this->designerService = $designerService;
    }

    public function index(Request $request)
    {
        $designers = $this->designerService->index($request->all());
        return $this->successData($designers);
    }

    public function create()
    {
        return $this->successData();
    }

    public function store(DesignerRequest $request)
    {
        $this->designerService->set($request->filldata());
        return $this->success();
    }

    public function edit($id)
    {
        $designer = $this->designerService->get($id);
        return $this->successData(compact('designer'));
    }

    public function update(DesignerRequest $request, $id)
    {
        $this->designerService->set($request->filldata(), $id);
        return $this->success();
    }

    public function destroy($id)
    {
        $this->designerService->destroy($id);
        return $this->success();
    }
}
